<?php
class setmenu extends CP_Controller{
    //put your code here
    function __construct() {
        parent::__construct('tc_album','album_','id');
        
        
    }
    function index(){
		$type="";
		$this->assigns->type_list = $this->db
                ->where('type_type','Product')
                ->get('tc_type')
				->result();
		if(isset($this->assigns->type_list[0])){
			$type = $this->assigns->type_list[0]->type_id;
		}
        $this->viewport($type);
    }
	function viewport($type=''){
		$this->assigns->type=$type;
		echo $c=$this->load->view('cms/cp/tc_setmenu/viewport',$this->assigns,true);
	}
	function bindingbytype($type=null){
		$where = "WHERE TRUE";
		if(!empty($type)) $where = "WHERE album_type = '$type'";
		$this->backend_model->datatables_config=array(
				"table"=>"`$this->table`",
				"select"=>"SELECT SQL_CALC_FOUND_ROWS * ",
				"from"=>"FROM `$this->table`",
				"where"     =>"$where",
				"order_by"=>"ORDER BY `album_insert` DESC",
				"columnmaps"=>array(
						
				)
		);
		$this->bindingdata();
	}
	function bindingimagebyalbumid($albumid=null){
		$where = "WHERE TRUE";
		if(!empty($albumid)) $where = "WHERE image_album_id = '$albumid'";
		$this->backend_model->datatables_config=array(
				"table"=>"`tc_image`",
				"select"=>"SELECT SQL_CALC_FOUND_ROWS * ",
				"from"=>"FROM `tc_image`",
				"where"     =>"$where",
				"order_by"=>"ORDER BY `image_insert` DESC",
				"columnmaps"=>array(
						
				)
		);
		$this->bindingdata();
	}
	function editpanel($type=''){
		$this->assigns->type=$type;
        $Id=(int)$this->input->post('Id');
		$this->assigns->code = md5(time().random_string('alnum', 8));
        if(!empty($Id)){
            $this->assigns->item=$this->backend_model->onGet($Id);
			$this->assigns->type = $this->assigns->item->album_type;
		}
		switch($type){
			default:
				$c=$this->load->view('cms/cp/tc_setmenu/editpanel',$this->assigns,true);
		}
        
        $R["result"] = 1;
        $R["message"]='SUCCESS !';
        $R["htmlreponse"]=$c;
        $this->output->set_header('Content-type: application/json');
        $this->output->set_output(json_encode($R));
    }
	
	function imageeditpanel($albumid=''){
		$this->assigns->albumid=$albumid;
        $Id=(int)$this->input->post('Id');
        if(!empty($Id)){
            $this->assigns->item=$this->backend_model->onGet($Id);
		}
		switch($type){
			default:
				$c=$this->load->view('cms/cp/tc_album/editpanelimage',$this->assigns,true);
		}
        
        $R["result"] = 1;
        $R["message"]='SUCCESS !';
        $R["htmlreponse"]=$c;
        $this->output->set_header('Content-type: application/json');
        $this->output->set_output(json_encode($R));
    }
}

?>
